import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '人员',
    align: "center",
    sorter: true,
    dataIndex: 'outsourcePersonAccountId_dictText'
  },
  {
    title: '原订单编号',
    align: "center",
    sorter: true,
    dataIndex: 'oldOrderNo'
  },
  {
    title: '原部门',
    align: "center",
    sorter: true,
    dataIndex: 'oldDepartId'
  },
  {
    title: '原项目',
    align: "center",
    sorter: true,
    dataIndex: 'oldProjectId'
  },
  {
    title: '原项目经理',
    align: "center",
    sorter: true,
    dataIndex: 'oldPmId'
  },
  {
    title: '原项目经理电话',
    align: "center",
    sorter: true,
    dataIndex: 'oldPmMobile'
  },
  {
    title: '原质量对接人',
    align: "center",
    sorter: true,
    dataIndex: 'oldTestLiaison'
  },
  {
    title: '原工作地点',
    align: "center",
    sorter: true,
    dataIndex: 'oldWorkPlace'
  },
  {
    title: '原合同开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'oldContractStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '原合同结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'oldContractEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '原入项时间',
    align: "center",
    sorter: true,
    dataIndex: 'oldEntryTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '原离项时间',
    align: "center",
    sorter: true,
    dataIndex: 'oldDepartureTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '所属部门',
    align: "center",
    sorter: true,
    dataIndex: 'departId_dictText'
  },
  {
    title: '项目',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '订单编号',
    align: "center",
    sorter: true,
    dataIndex: 'orderNo'
  },
  {
    title: '项目经理',
    align: "center",
    dataIndex: 'pmId_dictText'
  },
  {
    title: '项目经理电话',
    align: "center",
    dataIndex: 'pmMobile'
  },
  {
    title: '质量对接人',
    align: "center",
    dataIndex: 'testLiaison_dictText'
  },
  {
    title: '职场地点',
    align: "center",
    dataIndex: 'workPlace_dictText'
  },
  {
    title: '合同开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '合同结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '入项时间',
    align: "center",
    sorter: true,
    dataIndex: 'entryTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '离项时间',
    align: "center",
    sorter: true,
    dataIndex: 'departureTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'comments'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "人员",
    field: 'outsourcePersonAccountId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_outsource_person_account,real_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "原订单编号",
    field: 'oldOrderNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "原部门",
    field: 'oldDepartId',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "原项目",
    field: 'oldProjectId',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "原项目经理",
    field: 'oldPmId',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "原质量对接人",
    field: 'oldTestLiaison',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "原合同开始时间",
    field: "oldContractStartTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "原合同结束时间",
    field: "oldContractEndTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "原入项时间",
    field: "oldEntryTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "原离项时间",
    field: "oldDepartureTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "所属部门",
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart,depart_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "订单编号",
    field: 'orderNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "合同开始时间",
    field: "contractStartTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "合同结束时间",
    field: "contractEndTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "入项时间",
    field: "entryTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "离项时间",
    field: "departureTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员',
    field: 'outsourcePersonAccountId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_outsource_person_account,real_name,id"
    },
    dynamicDisabled: true
  },
  {
    label: '原订单编号',
    field: 'oldOrderNo',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原部门',
    field: 'oldDepartId',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原项目',
    field: 'oldProjectId',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原项目经理',
    field: 'oldPmId',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原项目经理电话',
    field: 'oldPmMobile',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原质量对接人',
    field: 'oldTestLiaison',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原工作地点',
    field: 'oldWorkPlace',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '原合同开始时间',
    field: 'oldContractStartTime',
    component: 'DatePicker',
    dynamicDisabled: true
  },
  {
    label: '原合同结束时间',
    field: 'oldContractEndTime',
    component: 'DatePicker',
    dynamicDisabled: true
  },
  {
    label: '原入项时间',
    field: 'oldEntryTime',
    component: 'DatePicker',
    dynamicDisabled: true
  },
  {
    label: '原离项时间',
    field: 'oldDepartureTime',
    component: 'DatePicker',
    dynamicDisabled: true
  },
  {
    label: '所属部门',
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart,depart_name,id"
    },
  },
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '订单编号',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入订单编号!'},
             ];
    },
  },
  {
    label: '项目经理',
    field: 'pmId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目经理!'},
             ];
    },
  },
  {
    label: '项目经理电话',
    field: 'pmMobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目经理电话!'},
             ];
    },
  },
  {
    label: '质量对接人',
    field: 'testLiaison',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入质量对接人!'},
             ];
    },
  },
  {
    label: '职场地点',
    field: 'workPlace',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_work_place,work_place,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入职场地点!'},
             ];
    },
  },
  {
    label: '合同开始时间',
    field: 'contractStartTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同开始时间!'},
             ];
    },
  },
  {
    label: '合同结束时间',
    field: 'contractEndTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同结束时间!'},
             ];
    },
  },
  {
    label: '入项时间',
    field: 'entryTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入入项时间!'},
             ];
    },
  },
  {
    label: '离项时间',
    field: 'departureTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入离项时间!'},
             ];
    },
  },
  {
    label: '备注',
    field: 'comments',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  outsourcePersonAccountId: {title: '人员',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_outsource_person_account", dictCode: 'id', dictText: 'real_name',},
  oldOrderNo: {title: '原订单编号',order: 1,view: 'text', type: 'string',},
  oldDepartId: {title: '原部门',order: 2,view: 'text', type: 'string',},
  oldProjectId: {title: '原项目',order: 3,view: 'text', type: 'string',},
  oldPmId: {title: '原项目经理',order: 4,view: 'text', type: 'string',},
  oldPmMobile: {title: '原项目经理电话',order: 5,view: 'text', type: 'string',},
  oldTestLiaison: {title: '原质量对接人',order: 6,view: 'text', type: 'string',},
  oldWorkPlace: {title: '原工作地点',order: 7,view: 'text', type: 'string',},
  oldContractStartTime: {title: '原合同开始时间',order: 8,view: 'date', type: 'string',},
  oldContractEndTime: {title: '原合同结束时间',order: 9,view: 'date', type: 'string',},
  oldEntryTime: {title: '原入项时间',order: 10,view: 'date', type: 'string',},
  oldDepartureTime: {title: '原离项时间',order: 11,view: 'date', type: 'string',},
  departId: {title: '所属部门',order: 12,view: 'sel_search', type: 'string',dictTable: "sys_depart", dictCode: 'id', dictText: 'depart_name',},
  projectId: {title: '项目',order: 13,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  orderNo: {title: '订单编号',order: 14,view: 'text', type: 'string',},
  pmId: {title: '项目经理',order: 15,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  pmMobile: {title: '项目经理电话',order: 16,view: 'text', type: 'string',},
  testLiaison: {title: '质量对接人',order: 17,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  workPlace: {title: '职场地点',order: 18,view: 'list', type: 'string',dictTable: "tm_work_place", dictCode: 'id', dictText: 'work_place',},
  contractStartTime: {title: '合同开始时间',order: 19,view: 'date', type: 'string',},
  contractEndTime: {title: '合同结束时间',order: 20,view: 'date', type: 'string',},
  entryTime: {title: '入项时间',order: 21,view: 'date', type: 'string',},
  departureTime: {title: '离项时间',order: 22,view: 'date', type: 'string',},
  comments: {title: '备注',order: 23,view: 'textarea', type: 'string',},
};
